package Pre.treeMap;

import java.util.Enumeration;
import java.util.Hashtable;

public class HashTableTest {
    public static void main(String[] args) {
        Hashtable<Integer,String> hashtable = new Hashtable<>();
        hashtable.put(1, "《长风渡》");
        hashtable.put(2, "《还珠格格》");
        hashtable.put(3, "《甄嬛传》");
        hashtable.put(4, "《开发喵大电影》");
        hashtable.forEach((k, v) -> {
            System.out.println(k + "-->" + v);
        });

        // 获取值的枚举
        Enumeration<String> enumeration = hashtable.elements();
        while (enumeration.hasMoreElements()){
            String str = enumeration.nextElement();
            System.out.println(str);
        }
        Enumeration<Integer> keys = hashtable.keys();
        while (keys.hasMoreElements()){
            System.out.println(keys.nextElement());
        }

    }
}
